package com.bookmanage.dao;

import com.bookmanage.utils.DBUitls;

import java.sql.*;

public class ModifyBook {
    public static void modify(int isbn, int price, String author, String publish, String bookname) {
        try {
            Connection conn = DBUitls.getConn();

            String sql = "update book set isbn=?,price=?,author=?,publish=? where bookname=? ";
            //预处理编译sql
            PreparedStatement pst = (PreparedStatement) conn.prepareStatement(sql);
            //设置数据库的五个参数
            pst.setInt(1, isbn);
            pst.setInt(2, price);
            pst.setString(3, author);
            pst.setString(4, publish);
            pst.setString(5, bookname);
            pst.executeUpdate();

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
